package org.zhangjq.myproject.transactiontest;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 功能描述
 *
 * @author: zhangjq
 * @date: 2024年01月20日 11:51
 */
@Service
public class ServiceA {

    @Resource
    private ServiceB serviceB;
    @Resource
    private UserMapper userMapper;

    @Transactional(rollbackFor = Exception.class)
    public void methodA() {
        User user = new User();
        user.setName("zhang");
        user.setAge(18);
        serviceB.methodB(user);
//        try {
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }

        User user1 = new User();
        user1.setName("zhang1");
        user1.setAge(19);
        userMapper.insert(user1);

    }
}